/**
 * @desc 全局注册 components
 *    components/home/one.vue   ==>  <home-one />
 *    components/homeList.vue   ==>  <home-list />
 */

export default {
    install: (app: any) => {
        const requireComponent = import.meta.globEager('../components/**/*.vue')
        for (let key in requireComponent) {
            const componentName = key
                .replace(/\.\w+$/, '') //替换.vue 扩展名
                .replace(/(\.\/)|(\..\/)/g, '') //替换 ./../../
                .replace(/components\//g, '')//替换 components/
                .replace(/\//g, '-'); //把/替换成-
            app.component(componentName, requireComponent[key].default);
        }
    }
}
